package cn.holy.app.sztxc.net;

import cn.holy.app.sztxc.cons.AppUrl;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by xionghao on 2018/2/23.
 */

public class ApiClient {
    private static OkHttpClient okHttpClient=new OkHttpClient();
    private static Retrofit getRetrofit(String url, OkHttpClient client){
        return new Retrofit.Builder()
                .client(client)
                .baseUrl(url)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }
    public static Webservice getWebService(){
        return getRetrofit(AppUrl.BASE_URL,okHttpClient.newBuilder().build()).create(Webservice.class);
    }
}
